use serde::{Deserialize, Serialize};

use crate::esb::head::{AppHead, LocalHead, SysHead};

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename = "service", rename_all = "lowercase")]
pub struct Body270002 {
    pub body: Zlc270002,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename = "service", rename_all = "lowercase")]
pub struct Service {
    #[serde(rename = "sys-header")]
    pub sys: SysHead,
    #[serde(rename = "app-header")]
    pub app: AppHead,
    #[serde(rename = "local-header")]
    pub local: LocalHead,
    pub body: Zlc270002,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename = "skip")]
pub struct Zlc270002 {
    #[serde(rename(
        serialize = "SYSTEM_WORK_DATE,string,8,0",
        deserialize = "SYSTEM_WORK_DATE"
    ))]
    pub system_work_date: Option<String>,
    #[serde(rename = "HOLD_ARRAY")]
    pub hold_array: Option<Vec<Hold>>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename = "struct")]
pub struct Hold {
    #[serde(rename(serialize = "ORDER_NO,string,32,0", deserialize = "ORDER_NO"))]
    pub order_no: Option<String>,
    #[serde(rename(serialize = "PROD_CODE,string,32,0", deserialize = "PROD_CODE"))]
    pub prod_code: Option<String>,
    #[serde(rename(serialize = "PROD_NAME,string,32,0", deserialize = "PROD_NAME"))]
    pub prod_name: Option<String>,
    #[serde(rename(serialize = "MIN_HOLD_DAY,string,32,0", deserialize = "MIN_HOLD_DAY"))]
    pub min_hold_day: Option<String>,
    #[serde(rename(serialize = "BUY_AMOUNT,string,32,0", deserialize = "BUY_AMOUNT"))]
    pub buy_amount: Option<f64>,
    #[serde(rename(serialize = "HOLD_AMOUNT,string,32,0", deserialize = "HOLD_AMOUNT"))]
    pub hold_amount: Option<f64>,
    #[serde(rename(serialize = "APPLY_AMOUNT,string,32,0", deserialize = "APPLY_AMOUNT"))]
    pub apply_amount: Option<f64>,
    #[serde(rename(
        serialize = "ORIGINAL_START_RATE_DATE,string,32,0",
        deserialize = "ORIGINAL_START_RATE_DATE"
    ))]
    pub original_start_rate_date: Option<String>,
    #[serde(rename(
        serialize = "START_RATE_DATE,string,32,0",
        deserialize = "START_RATE_DATE"
    ))]
    pub start_rate_date: Option<String>,
    #[serde(rename(serialize = "BUY_DATE,string,32,0", deserialize = "BUY_DATE"))]
    pub buy_date: Option<String>,
    #[serde(rename(serialize = "END_DATE,string,32,0", deserialize = "END_DATE"))]
    pub end_date: Option<String>,
    #[serde(rename(
        serialize = "ORDER_TRANSFERABLE_DATE,string,32,0",
        deserialize = "ORDER_TRANSFERABLE_DATE"
    ))]
    pub order_transferable_date: Option<String>,
    #[serde(rename(serialize = "BASIC_RATE,string,32,0", deserialize = "BASIC_RATE"))]
    pub basic_rate: Option<f32>,
    #[serde(rename(serialize = "FROZEN_AMOUNT,string,32,0", deserialize = "FROZEN_AMOUNT"))]
    pub frozen_amount: Option<f64>,
    #[serde(rename(serialize = "ORDER_STATUS,string,32,0", deserialize = "ORDER_STATUS"))]
    pub order_status: Option<String>,
    #[serde(rename(
        serialize = "PROVISION_DATE,string,32,0",
        deserialize = "PROVISION_DATE"
    ))]
    pub provision_date: Option<String>,
    #[serde(rename(
        serialize = "PROVISION_INTEREST,string,32,0",
        deserialize = "PROVISION_INTEREST"
    ))]
    pub provision_interest: Option<f32>,
    #[serde(rename(serialize = "TERM,string,32,0", deserialize = "TERM"))]
    pub term: Option<String>,
    #[serde(rename(serialize = "TERM_TYPE,string,32,0", deserialize = "TERM_TYPE"))]
    pub term_type: Option<String>,
    #[serde(rename(serialize = "SAVED_DAYS,string,32,0", deserialize = "SAVED_DAYS"))]
    pub saved_days: Option<u16>,
    #[serde(rename(serialize = "LAST_HOLD_AMT,string,32,0", deserialize = "LAST_HOLD_AMT"))]
    pub last_hold_amt: Option<f64>,
    #[serde(rename(
        serialize = "REMAIN_FULL_INTEREST,string,32,0",
        deserialize = "REMAIN_FULL_INTEREST"
    ))]
    pub remain_full_interest: Option<f64>,
    #[serde(rename(serialize = "REMAIN_DAYS,string,32,0", deserialize = "REMAIN_DAYS"))]
    pub remain_days: Option<u16>,
    #[serde(rename(serialize = "SIG_MINBUYAMT,string,32,0", deserialize = "SIG_MINBUYAMT"))]
    pub sig_minbuyamt: Option<f32>,
    #[serde(rename(
        serialize = "DRAW_MIN_AMOUNT,string,32,0",
        deserialize = "DRAW_MIN_AMOUNT"
    ))]
    pub draw_min_amount: Option<f32>,
    #[serde(rename(
        serialize = "DRAW_STEP_AMOUNT,string,32,0",
        deserialize = "DRAW_STEP_AMOUNT"
    ))]
    pub draw_step_amount: Option<f32>,
    #[serde(rename(
        serialize = "TRANSFER_MINBUYAMT,string,32,0",
        deserialize = "TRANSFER_MINBUYAMT"
    ))]
    pub transfer_minbuyamt: Option<f32>,
    #[serde(rename(serialize = "BUY_STEPAMT,string,32,0", deserialize = "BUY_STEPAMT"))]
    pub buy_stepamt: Option<f32>,
    #[serde(rename(
        serialize = "WIDTHDRAW_SUBSTRACT_BANKPAY,string,32,0",
        deserialize = "WIDTHDRAW_SUBSTRACT_BANKPAY"
    ))]
    pub widthdraw_substract_bankpay: Option<String>,
    #[serde(rename(serialize = "CURRENT_RATE,string,32,0", deserialize = "CURRENT_RATE"))]
    pub current_rate: Option<f32>,
    #[serde(rename(
        serialize = "DRAW_FROZEN_AMOUNT,string,32,0",
        deserialize = "DRAW_FROZEN_AMOUNT"
    ))]
    pub draw_frozen_amount: Option<f64>,
    #[serde(rename(
        serialize = "TOTAL_BANK_PAY_INTEREST,string,32,0",
        deserialize = "TOTAL_BANK_PAY_INTEREST"
    ))]
    pub total_bank_pay_interest: Option<f32>,
    #[serde(rename(
        serialize = "SECKILL_STATUS,string,32,0",
        deserialize = "SECKILL_STATUS"
    ))]
    pub seckill_status: Option<String>,
    #[serde(rename(serialize = "PROD_CLASS,string,32,0", deserialize = "PROD_CLASS"))]
    pub prod_class: Option<String>,
    #[serde(rename(
        serialize = "PERIOD_PAY_INTEREST_DAYS,string,32,0",
        deserialize = "PERIOD_PAY_INTEREST_DAYS"
    ))]
    pub period_pay_interest_days: Option<u16>,
    #[serde(rename(
        serialize = "CURRENT_PERIOD_START_DATE,string,32,0",
        deserialize = "CURRENT_PERIOD_START_DATE"
    ))]
    pub current_period_start_date: Option<String>,
    #[serde(rename(
        serialize = "CURRENT_PERIOD_END_DATE,string,32,0",
        deserialize = "CURRENT_PERIOD_END_DATE"
    ))]
    pub current_period_end_date: Option<String>,
    #[serde(rename(
        serialize = "CURRENT_PERIOD_GET_AMOUNT,string,32,0",
        deserialize = "CURRENT_PERIOD_GET_AMOUNT"
    ))]
    pub current_period_get_amount: Option<f32>,
    #[serde(rename(
        serialize = "CURRENT_PERIOD_EXPECT_END_DATE,string,32,0",
        deserialize = "CURRENT_PERIOD_EXPECT_END_DATE"
    ))]
    pub current_period_expect_end_date: Option<String>,
}
